
	function createIssueDashBoardGrid(projectId,IssueId,rowdata){  
		
 // Search Store
 var dashBoardStore = CRM.commons.createStore('dashboardStoreId',CRM.SPComp.dashboardDataArray,'searchIssueDashboard/showIssueDetails');
 var issueHomeGrid=CRM.commons.createGrid('issueHomeGrid',dashBoardStore,CRM.SPComp.createDashboardColumnModel());
 
 var projectStore = CRM.commons.createComboStore('projectStoreId','searchIssueDashboard/projectSearchTypes'); 
 var assignedByStore = CRM.commons.createComboStore('assignedByStore','searchIssueDashboard/reportSearchTypes');
 var dashboardAssignedToStore = CRM.commons.createComboStore('assignedToStore','searchIssueDashboard/assignSearchTypes');		 
 var priorityStore = CRM.commons.createComboStore('priorityStoreId','searchIssueDashboard/prioritySearchTypes');   
		 
 var criteriaPanel = {
			 xtype       : 'fieldset',
			 title		 : 'Search Issues',
		     id          : 'criteriaPanel',
		     width       : '98%', 
		     labelWidth  : 120,
		     border      : true,
		     layout      : 'hbox',
		     items       : [
		                      {
		                    	 xtype : 'compositefield',
		                    	 items : [

		                     	          { 	xtype : 'displayfield', value : '<b>Created By :</b> '},
										  {
											   	xtype        : 'combo',
											   	id           : 'assignedBy',
											   	valueField   : 'id',
											   	value        :'SELECT',
										    	store        : assignedByStore,
										    	displayField : 'name',
										    	triggerAction: 'all',
										    	typeAhead    : true,
										    	editable     : false,
										    	autoLoad     : false,
										    	width        : 180,
										    	mode         : 'local'
										   },
										  { xtype : 'displayfield', value : '<b>Assigned To :</b> '},
		                       			  { 
		                       				    xtype        : 'combo',
		                                        id           : 'issueDashBoardAsssignedTo',  
		                                        valueField   : 'id',
		                                        value		 : 'SELECT',
		                                        store        : dashboardAssignedToStore,
		                                        displayField : 'name',
		                                        triggerAction: 'all',
		                                        typeAhead    : true,
		                                        editable     : false,
		                                        autoLoad     : false,
		                                        width        : 180,
		                                        mode         : 'local'
		                       				} ,
		                    	            { 	xtype : 'displayfield', value : '<b>Project :<b>'},
		                       			    {
		                    	   			    xtype 		: 'combo',
		                    	   				id	  		: 'project',
		                    	   				store		:  projectStore,
		                                        displayField: 'name',
		                                        valueField  : 'id',
		                                        value		: 'SELECT',
		                                        triggerAction:'all',
		                    	   				width 		: 180,
		                    	   				editable	: false,
		                    	   			    listeners	: {select : function(combo,record,index){
		                    	            	reloadDashboardCombo(record.get('id'),dashboardAssignedToStore);
		                    	            	reloadDashboardCombo(record.get('id'),assignedByStore);
		                    	            	reloadDashboardCombo(record.get('id'),priorityStore);
		                    					  				} 
		                    			      				  }
		                       				},
		                       			    { xtype : 'displayfield', value : '<b>Priority :</b> '},
		                       				{
		                                        xtype        : 'combo',
		                                        id           : 'issueDashboardPriority', 
		                                        valueField   : 'id',
		                                        value        :'SELECT',
		                                        store        : priorityStore  ,      
		                                        displayField : 'name',
		                                        triggerAction: 'all',
		                                        typeAhead    : true,
		                                        editable     : false,
		                                        autoLoad     : false,
		                                        width        : 180
		                       				}, 
		                       				 {
			                       				xtype 		 : 'button',
				                       			text  	     : 'Search',
				                       			handler 	 : function(){
				                       								doSearch(false);
				                       						 	}
			                       			 },
		                        				 {
		                       				   	xtype	: 'button',
		                       				   	text	: 'Clear Search',
		                       				   	handler : function(){
		                       				    				var dashboardGrid = Ext.getCmp('issueDashBoardGrid');
		                       				    				dashboardGrid.store.removeAll();
		                       				    			 }
		                       				  }
		                       				
		                    			]
		                       }]
				};
		 
          
	      //Priority image path
	     	var High_Priority = '../images/high_priority2.gif';
	     	var Low_Priority  = '../images/Low_priority.jpeg';
	     	var Medium_Priority = '../images/High_Priority_1.jpeg';
	     	
	     	// Status Image Path
	     	
	     	var Open_Status = '../images/Open_status.jpeg'; 
	     	var Inprogress_Status = '../images/Inprogress_status.jpeg';
	     	var Closed_Status = '../images//Closed_Status.jpeg';
	     	var Testing_Status = '../images/Testing_status.jpeg'; 
	     	var Resolved_Status = '../images/Resolved_status.jpeg';
	     	var Reopen_Status= '../images/Reopen_Status.jpeg';
	     	var Reclose_Status = '../images/Reclose_Status.jpeg';
	     	
	     	
   	// Code For Grid
	     	var gridView = new Ext.grid.GridView();
	     	var selModel = new Ext.grid.RowSelectionModel({singleSelect : true}); 
	     	var issueDashBoardGrid = new Ext.grid.GridPanel({
	       	      autoHeight 	: true,
	       	      id			: 'issueDashBoardGrid',
	       	      view 			: gridView,
	       	      store			: dashBoardStore,
	       	     // colModel 		: dashboardColModel ,	 	
	       	      selModel 		: selModel,
	       	      autoScroll : true,
	       	      stripeRows	: true,
	       	      enableRowBody : true,
	       	      scrollable	: true,
	       	      width	        : '99.5%',
	              height        : 300,   
	              frame	        : true,
	              title	        : 'Issue Dashboard', 
	              iconCls       : 'icon-grid',
	              //columnLines   : true,
	       	      columns		: [
	       	             		   {hidden	: true,index : 'projectId'},
	       	             		   {
	       	             			 header   	: 'Issue Id',
						             align    	:'left',
						             width    	: 80,
						             sortable 	: true,
						             index    	: 'Id'
						             
						           },
	       	             	       {
	       	                        header   	: 'Project Name',
	       	                        align    	:'left',
	       	                        width    	: 150,
	       	                        sortable 	: true,
	       	                        index    	:'projectName'
	       	                        
	       	                       },
       	                          {
	       	                         header    :'Issue Name',
	       	                         align    	:'left',
	       	                         width     : 150,
	       	                         sortable  : true,
	       	                         index     :'issueName'
       	                          },
		       	                  {
		        	                  header  : 'Created By',
		        	                  align    	:'left',
		       	                      width   : 100,
		       	                      sortable: true,
		       	                      index   :'createdBy'
		       	                      
		       	                  },
		       	                  {
		       	                      header  : 'Assigned To', 
		       	                      align    	:'left',
		       	                      width   : 100,
		       	                      sortable: true,
		       	                      index   : 'issueAssignedTo'
		       	                  },
		       	                 {hidden	: true,index : 'issueAssignedToId'},  
		       	                  {
		       	                       header    :'Priority',
		       	                       align     :'left',
		       	                       width     : 150,
		       	                       sortable  : true,
		       	                       index     : 'issuePriority',
		       	                       renderer  : renderPriorityIcon
		       	                  },
		       	                  {hidden	: true,index : 'issuePriorityId'},
		       	                  {
		       	                      header  : 'Status',
		       	                      align   :'left',
		       	                      width   : 150,
		       	                      sortable: true,
		       	                      index   : 'issueStatus',
		       	                      renderer  : renderStatusIcon
		       	                  },
		       	                 {hidden	: true,index : 'issueStatusId'},
		       	                  {
		       	                      header  :'Resolution',
		       	                      align   :'left',
		       	                      width   :100,
		       	                      sortable: true,
		       	                      index   :'issueResolution'
		       	                      
		       	                  },
		       	                  {hidden	: true,index : 'issueResolutionId'},  
		       	                 {
		       	                      header  :'Category',
		       	                      align   :'left',
		       	                      width   :100,
		       	                      sortable: true,
		       	                      index   :'issueCategory'
		       	                      
		       	                  },
		       	                 {hidden	: true,index : 'issueCategoryId'}, 
		       	                 {
		       	                     header  : 'Date',
		       	                     align  :'left',
		       	                     width   : 100,
		       	                     sortable: true,
		       	                     index   : 'date'
		       	                  }, 
			       	           
			       	           {hidden  : true,index : 'issueReason'},
			       	           {hidden  : true,index : 'issueModule'},
			       	           {hidden	: true,index : 'issueComplexity'},
			       	           {hidden	: true,index : 'issueComplexityId'},
			       	           {hidden	: true,index : 'targetDate'},
			       	           {hidden	: true,index : 'dateResolved'}, 
			       	           
			       	           {
			       	                      xtype    :'actioncolumn', 
			        	                  header   : 'Action',
			        	                  align    : 'center', 
			       	                      width    : 120, 
			       	                      items    :[
			       	                                 {
						       	                       icon     : '../images/Edit.jpeg', 
						       	                       tooltip  : 'Update',
						       	                       handler  : function(cm, rowIndex, colIndex){
						       	                                var issueDashBoardGrid = Ext.getCmp('issueDashBoardGrid');
						       	              				    var rowData  = issueDashBoardGrid.store.getAt(rowIndex); 
						       	              				    issuePopupWindow( rowData,false,true);   // this method is in issueDetails.js   
			       	                                	 
			       	                                  } 
		                                           },'-', 
			       	                               {
			       	                       	           icon      : '../images/view.jpg',
			       	                       	           tooltip   : 'View',
			       	                       	           handler   : function(cm, rowIndex, colIndex){
					       	                                     var issueDashBoardGrid = Ext.getCmp('issueDashBoardGrid');
					       	              				         var rowData  = issueDashBoardGrid.store.getAt(rowIndex); 
					       	              				         issuePopupWindow( rowData,true,true);   // this method is in issueDetails.js
		                                               } 
			       	                               },'-',
			       	                               {
			       	                                  icon    : '../images/cross.gif',
			       	                                  id      : 'deleteIcon',
			       	                                  tooltip :'Delete',
			       	                                  handler : function(cm, rowIndex, colIndex){
			       	                                     var issueDashBoardGrid = Ext.getCmp('issueDashBoardGrid');
			       	              				         var rowData  = issueDashBoardGrid.store.getAt(rowIndex); 
			       	              				         issuePopupWindow(rowData,true,false);    // this method is in IssueDetails.js
                                                  } 
			       	                            }
			       	                          ]
			       	                  }
       	                
       		   	]
	       	     

	              
	       	   });		 
		
			 var dynamicGridPanel = new Ext.Panel({
		     		width    : '100%',
		     		padding	 : '5px',
		     		frame	 : true,
		     		autoScroll : true,
		     		height   : 400,
		     		items 	 : [criteriaPanel, issueDashBoardGrid]
	     	});
	     	
			
			 
			// Priority renderer function
			 function renderPriorityIcon(val) {
				 if(val == 'High')
			     return  '<img src="' + High_Priority  + '"> ' + val  ;
				 if(val == 'Low')
				     return  '<img src="' + Low_Priority   + '"> ' + val  ;
				 if(val == 'Medium')
				     return  '<img src="' + Medium_Priority  + '"> ' + val  ;
			 }
			 
			 // Status render function
            function renderStatusIcon(val) {
				 if(val == 'Open') 
			     return  '<img src="' + Open_Status  + '"> ' + val  ;
				 if(val == 'Inprogress')
				     return  '<img src="' + Inprogress_Status  + '"> ' + val  ;
				 if(val == 'Closed')
				     return  '<img src="' + Closed_Status  + '"> ' + val  ; 
				 if(val == 'Testing')
					     return  '<img src="' + Testing_Status + '"> ' + val ;
				 if(val == 'Resolved')
				     return  '<img src="' + Resolved_Status + '"> ' + val ; 
				 if(val == 'Reopen')
					     return  '<img src="' + Reopen_Status + '"> ' + val ; 
				 if(val == 'Reclosed')
				     return  '<img src="' + Reclose_Status + '"> ' + val ; 
			 }
			 
	     	
	     	function doSearch(ONKEYEVENT){ 
	     		
	     		var projectSelectedCriteria    = Ext.getCmp('project');
	     		var assignedBySelectedCriteria = Ext.getCmp('assignedBy');
	     		var assignedToSearchCriteria   = Ext.getCmp('issueDashBoardAsssignedTo');
	      		var prioritySearchCriteria     = Ext.getCmp('issueDashboardPriority');
	     		
	     		if(projectSelectedCriteria.getValue() == 'SELECT' &&  assignedBySelectedCriteria.getValue() == 'SELECT' && assignedToSearchCriteria.getValue() == 'SELECT' && prioritySearchCriteria.getValue()=='SELECT' )
				{
 					Ext.Msg.alert('Alert','Please Select a Criteria');
 				}
	     		else{
 				//if(projectSelectedCriteria != 'SELECT' &&  assignedBySelectedCriteria != 'SELECT' && assignedToSearchCriteria != 'SELECT' ){
 					var dashboardGrid = Ext.getCmp('issueDashBoardGrid');
 					dashboardGrid.store.removeAll();
 					dashboardGrid.store.reload({
			    			params: {
						            projectCriteria	: projectSelectedCriteria.getValue(),
						            reportedCriteria:assignedBySelectedCriteria.getValue(),
						            assignCriteria	:assignedToSearchCriteria.getValue(),
						            priorityCriteria :prioritySearchCriteria.getValue()  
			    					}
			    				});
 				}
	     	};
		
		return dynamicGridPanel; 
	};
	

	
	function reloadDashboardCombo(selectedProjectId,assignedStore){ 
		assignedStore.removeAll();
		assignedStore.reload({
							params : {
									projectId : selectedProjectId
									}
							});
		
		
	};
	
	
	
	
	



